Hi friends,
I'm trying to create a custom registration form. I've created a new page (/register) with the following code in the views:
@Html.ActionLink("Register", "RenderRegister", "Register");
Basically, this page displays a button that takes me to a form. I've created a controller with the ActionResults method Register and the RenderRegister method. In the code of the form's Partial View, I have:
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@model RegisterViewModel
@using Ikea.ViewModel;
@using Ikea.Controllers;
@using (Html.BeginUmbracoForm
("HandleRegister"))
{
Add registration details
@Html.AntiForgeryToken()
@Html.LabelFor(x => x.FirstName)
@Html.TextBoxFor(x=>x.FirstName, new {@class="form-control", @type="text"})
@Html.ValidationMessageFor(x=>x.FirstName)
}
Register 1
Register 2
None of the buttons are functional. They return "This page isn’t working right now. If the problem continues, contact the site owner." In the controller, I have another method, HandleRegister, with the following code:
if (!ModelState.IsValid)
{
return null;
}
var newMember = Services.MemberService.CreateMember(vm.Username, vm.Email, $"{vm.FirstName} {vm.LastName}", "Member");
Services.MemberService.Save(newMember);
Services.MemberService.CreateWithIdentity(vm.Username, vm.Email, vm.Password, "Normal User");
Services.MemberService.AssignRole(newMember.Id, "Normal User");
return View("HomePage");